import pkg from '../package.json';
import {
	VITE_BASE_URL,
	VITE_UPLOAD_URL,
	VITE_WS_URL,
	VITE_IMAGE_URL,
	VITE_SCAN_URL,
	VITE_APP_URL,
} from './http/url.js'

// Generate cache key according to version
export function getPkgVersion() {
	return `${`__${pkg.version}`}__`.toUpperCase();
}

/**
 * @description: Development mode
 */
export const devMode = 'development';

/**
 * @description: Production mode
 */
export const prodMode = 'production';

/**
 * @description: Get environment mode
 * @returns:
 * @example:
 */
export function getEnvMode() {
	return isDevMode() ? devMode : prodMode;
}

/**
 * @description: Get environment variables
 * @returns:
 * @example:
 */
const env = {
	VITE_BASE_URL,
	VITE_UPLOAD_URL,
	VITE_WS_URL,
	VITE_IMAGE_URL,
	VITE_SCAN_URL,
	VITE_APP_URL,
}
export function getEnvValue(key) {
	return env[key];
}

/**
 * @description: Is it a development mode
 * @returns:
 * @example:
 */
export function isDevMode() {
	return getEnvValue('VITE_DEV');
}

/**
 * @description: Is it a production mode
 * @returns:
 * @example:
 */
export function isProdMode() {
	return getEnvValue('VITE_PROD');
}